
const arr = [1,6,9,10,45,80,90,14]
const result = twoNum(arr, 91)
console.log(result);

function twoNum(nums, target){
    const newMap = new Map() 
    for (let i =0; i< nums.length;i++ ) {
        const numA = nums[i]
        const numB = target - numA 
        const j = newMap.has(numB)
        if(j) { 
            return [newMap.get(numB), i]
        }else {
            newMap.set(numA, i)
        }
    }
    return null
}
